package cn.sanshuilin.kst.common.utils;

import java.io.UnsupportedEncodingException;
import java.util.Date;

/**
 * 返回值
 * @author xutao
 * @version V1.0 创建时间：2017/11/21 18:39
 *          Copyright 2017 by 言午工作室
 */
public class Utility {

    /**
     * 返回成功
     */
    public static String RESULT_VALUE_OK="OK";


    public static String SessionKey_CurrentMember="SessionKey_CurrentMember";
    /**
     * 转换成UTF-8的字符串
     * @param str
     * @return
     */
    public static String toUtf8(String str){
        String newStr=str;
        try {
            newStr =  new String(str.getBytes("UTF-8"),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return newStr;
    }

    /**
     * 安全转发数字
     * @param intStr
     * @return
     */
    public static int toSafeInt(String intStr){
        int ret=-1;
        try {
            ret=Integer.parseInt(intStr);
        }catch (Exception ex){

        }
        return  ret;
    }
    //这个需要根据 入参 写一个 切割方法
    public static String[] getStrArray(String strIDs) {
        return null;
    }
    //字符串转 date 方法
    public static Date toSafeDateTime(String searchToDate) {

        return null;
    }
//需要实现
    public static String toSafeString(Object shareID) {
        return String.valueOf(shareID);
    }
//需要实现
    public static long toSafeLong(Object singleResult) {
        return Long.valueOf(String.valueOf(singleResult)).longValue();
    }

    public static boolean contains(String groupMenus, String s) {
      return   groupMenus.contains(s);
    }

    public static double toSafeDouble(String format) {
        double ret = -1;
        ret = Double.parseDouble(format);
        return ret;
    }
    //需要实现
    public static int toSafeInt(Object strMaxID, int i) {
        int i1 = Integer.parseInt((String) strMaxID);
        return i1;
    }
}
